<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
</head>
<body>
<div id="app">
    <button @click="handleRef">通过ref获取子组件实例</button>
    <component-a ref="comA"></component-a>
</div>
<script>
    Vue.component('component-a',{
        template:`<div>子组件</div>`,
        data() {
            return{
                message:'子组件内容'
            }
        }
    })
    var vm = new Vue({
        el:'#app',
        data:{},
        methods:{
            handleRef() {
                var msg = this.$refs.comA.message
                console.log(msg)
            }
        }
    })
</script>
</body>
</html>
